import {
    post,get
} from "./index.js";

export const userApi = {
    login(obj) {
        return post("/login.php", obj).then((res) => {
            console.log(res);
            if (res.ret === 200) {
                localStorage.setItem("userData", JSON.stringify(res))
            }
            return Promise.resolve(res)
        }).catch((err)=>{console.log(err)})
    },
    register(obj) {
        return post("/user/register.php", obj)
    },
    getCode(obj) {
        return post("/user/sms.php", obj)
    },
    isPhone(obj) {
        return post("/user/verifyPhone.php", obj)
    },
    getUserInfo() {
        return post("/user/currentUser.php")
    },
    sendImg(obj) {
        return post("/common/filesUpload.php", obj)
    },
    changeUserImg(obj){
        return post("/user/upLoadAvatar.php", obj)
    },
    changePassword(obj){
        return post("/user/modifyingCurrentUserPassword.php",obj)
    },
    exitLogin(){
        return post("/user/userOut.php")
       
    },
    changeUserInfo(obj){
        return post("/user/modifyingCurrentUser.php",obj)
    },
    getInfoById(obj){
        return post("/user/userPublicInfo.php",obj)
    }
}
export const artcle ={
    getcList(obj){
        return post("/category/list.php",obj)
    },
    getaList(obj){
        return post("/art/list.php",obj)
       
    },
    createCategory(obj){
        return post("/category/post.php",obj)
    },
    createTopics(obj){
        return post("/art/post.php",obj)

    },
    addSee(obj){
        return get("/art/articleViews.php",obj)
    }
}
